Human edit :
-
KV SCHEMA - completed.
-
8 KV pairs - we skip everything about trainer profile template for now. CSS not designed.
-
TEMPLATE VARIABLES - Proforma invoice and course schedule done. Trainer template future build.
-
Phase 3 COMPLETE — D1 migration + worker scaffold committed and pushed.
- migrations/0001_init.sql: enquiries + email_events tables
- wrangler.toml: DB, CAC_KV, ASSETS, BROWSER bindings
- GitHub Actions workflow: applies migration then deploys on push
- src/index.js: placeholder — Phase 4 rewrites it
-
Phase 4 COMPLETE — Worker rewrite committed and pushed.
- trainingbiz-admin-clerk/src/index.js: full lookup chain, pricing, PDF, Resend email, D1, Telegram
- sales-training/enquiry/index.html: worker_url updated, course_id + event_slug + form_type in payload
- resellers/newrise/sales-training/enquiry/index.html: new page built, grant-only
- Both templates fully de-hardcoded. Re-upload to R2 required after each git pull.
- puppeteer import removed — BROWSER binding used directly via env.BROWSER.newBrowser()
- Dead corporate-enquiry.yml workflow deleted
-
KNOWN ISSUE — Route claritysystems.work/* blocked the static Eleventy site. Removed.
Worker currently has NO route on main domain.
newrise.claritysystems.work/* route is set and correct.
-
PENDING before worker is live on main domain:
A. Worker secrets in CF dashboard (trainingbiz-admin-clerk > Settings > Variables):
- RESEND_API_KEY
- TELEGRAM_BOT_TOKEN = 8603272908:AAH5R-iw_OGEfTWxJMNKOYWTV_qOc9RSfXo
- TELEGRAM_CHAT_ID = 7918071148
B. D1 tables: verify enquiries + email_events exist in claritysystems-db console
SELECT name FROM sqlite_master WHERE type='table';
C. Re-upload both templates to R2 (cac-assets) after git pull — they are source of truth in repo
-
Phase 5 COMPLETE — Form routing fixed, grant claim payload aligned.
- Root cause: cac-corporate-enquiry worker was deleted. Forms were pointing at it.
- trainingbiz-admin-clerk is the live replacement (built Phase 4).
- No route change needed on claritysystems.work. Static site serves pages.
Forms POST directly to trainingbiz-admin-clerk.clarityawarenesscoaching.workers.dev.
CORS headers already in worker. No conflict with Eleventy.
- sales-training/enquiry/index.html: worker_url was already correct. No change needed.
- sales-training/request-hrdc-grant-claim/index.html: fixed worker URL + remapped payload:
pic_name → name, company_name → company, pax_total → pax
added: form_type='public', hrdc_option='grant', course_id='sales-technical', event_slug='20-05-26-penang-stgiles'
removed: stale fields (pax_paid, pax_free, total_amount_rm, course_title, training_date/time/city/venue, source)
- Committed and pushed: 1e2bb5d
-
Phase 5 — Route + Worker debugging log (2026-05-02)
PROBLEM 1: forms returning "something went wrong"
ROOT CAUSE: cac-corporate-enquiry worker deleted. Forms pointed at it.
FIX: update worker_url in both forms to trainingbiz-admin-clerk.
PROBLEM 2: 403 on workers.dev URL
ROOT CAUSE: Cloudflare Access was enabled on the worker (zero-trust toggle ON).
FIX: disabled Cloudflare Access toggle in Worker settings. Purged cache.
PROBLEM 3: 404 from worker
ROOT CAUSE: worker looked up domain:{host} in KV. Host was workers.dev URL, not claritysystems.work. KV key doesn't exist for workers.dev host.
DECISION: Option B — scoped routes on claritysystems.work (not a KV workaround key).
FIX:
- Added [[routes]] to wrangler.toml:
claritysystems.work/sales-training/enquiry
claritysystems.work/sales-training/request-hrdc-grant-claim
- Updated form fetch URLs from workers.dev to same-domain paths.
- Added GET passthrough in worker (return fetch(request)) so Eleventy pages still serve on GET.
- Updated form URLs:
enquiry: https://claritysystems.work/sales-training/enquiry
grant claim: https://claritysystems.work/sales-training/request-hrdc-grant-claim
PROBLEM 4: GitHub Actions failed to register routes
ROOT CAUSE: CLOUDFLARE_API_TOKEN missing Zone → Worker Routes → Edit permission.
FIX: edited token in CF dashboard → added Zone:Edit + Worker Routes:Edit for all zones. Re-ran job.
PROBLEM 5: 500 — TypeError: newBrowser is not a method
ROOT CAUSE: commit 90bba7b removed puppeteer import but changed launch call to env.BROWSER.newBrowser() which is not valid API.
FIX:
- Restored: import puppeteer from "@cloudflare/puppeteer"
- Restored: puppeteer.launch(env.BROWSER)
- Added @cloudflare/puppeteer to package.json dependencies
CONFIRMED: BROWSER binding visible in CF dashboard (Browser Run → BROWSER).
BINDINGS CONFIRMED ON trainingbiz-admin-clerk:
- R2: ASSETS → cac-assets
- Browser Run: BROWSER
- KV: CAC_KV
- D1: DB → claritysystems-db
- Phase 5 REMAINING — test and verify end-to-end:
A. Submit corporate enquiry form → verify email received with 3 PDFs attached
B. Submit grant claim form → verify email received with PDFs attached
C. Verify D1 enquiries table has the row written
D. Verify Telegram notification received
E. Verify invoice counter incremented in KV (invoice:last_number)
F. Purge Cloudflare cache after confirming forms work (in case stale HTML is served)
G. Update CAS_ARCHITECTURE.md to reflect Phase 3+4+5 decisions (deferred, do in dedicated session)